package com.prp.gwt.client.widgets.user.home;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.prp.gwt.client.vo.SubjectRecommendList;
import com.prp.gwt.client.widgets.user.article.SimpleRecommendItem;

public class PersonalArticalRecommend extends DecoratorPanel {

	private static PersonalArticalRecommend instance;
	private VerticalPanel innerPanel = new VerticalPanel();
	private static Grid table = new Grid(5, 2);
	private Image loadImage = new Image(GWT.getModuleBaseURL() + "loading.gif");

	public static PersonalArticalRecommend getIntance() {
		return instance;
	}

	public PersonalArticalRecommend() {
		instance = this;
		addStyleName("recommend-simple-panel");
		HTML title = new HTML("个性化推荐...");
		title.addStyleName("recommend-simple-panel-title");
		innerPanel.add(title);
		innerPanel.add(loadImage);
		innerPanel.add(table);
		add(innerPanel);
	}

	public void load(SubjectRecommendList list) {
		loadImage.setVisible(false);
		for (int i = 0; i < list.size(); i++)
			table.setWidget(i / 2, i % 2, new SimpleRecommendItem(list.get(i)));
	}

}
